import 'package:flutter/foundation.dart';

class LightScene {
  final String id;
  final String name;
  final String description;
  final String iconName;
  final double brightness;
  final double colorTemperature;
  final bool isCustom;

  LightScene({
    required this.id,
    required this.name,
    required this.description,
    required this.iconName,
    required this.brightness,
    required this.colorTemperature,
    this.isCustom = false,
  });

  // 从JSON创建场景
  factory LightScene.fromJson(Map<String, dynamic> json) {
    return LightScene(
      id: json['id'] as String,
      name: json['name'] as String,
      description: json['description'] as String,
      iconName: json['iconName'] as String,
      brightness: json['brightness'] as double,
      colorTemperature: json['colorTemperature'] as double,
      isCustom: json['isCustom'] as bool? ?? false,
    );
  }

  // 转换为JSON
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'description': description,
      'iconName': iconName,
      'brightness': brightness,
      'colorTemperature': colorTemperature,
      'isCustom': isCustom,
    };
  }

  // 创建场景副本
  LightScene copyWith({
    String? id,
    String? name,
    String? description,
    String? iconName,
    double? brightness,
    double? colorTemperature,
    bool? isCustom,
  }) {
    return LightScene(
      id: id ?? this.id,
      name: name ?? this.name,
      description: description ?? this.description,
      iconName: iconName ?? this.iconName,
      brightness: brightness ?? this.brightness,
      colorTemperature: colorTemperature ?? this.colorTemperature,
      isCustom: isCustom ?? this.isCustom,
    );
  }
}
